package common;

import java.util.Iterator;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;

public class TestListener implements ITestListener
{

	@Override
	public void onFinish(ITestContext context)
	{
		Iterator<ITestResult> listOfSkippedTests = context.getSkippedTests().getAllResults().iterator();
		while (listOfSkippedTests.hasNext())
		{
			ITestResult failedTest = listOfSkippedTests.next();
			ITestNGMethod method = failedTest.getMethod();
			if (context.getSkippedTests().getResults(method).size() >0 )
			{
				listOfSkippedTests.remove();
			}
			else
			{
				if (context.getPassedTests().getResults(method).size() > 0)
				{
					listOfSkippedTests.remove();
				}
			}
		}
		
	}

	// Following are all the method stubs that you do not have to implement

	public void onTestStart(ITestResult result)
	{
		// TODO Auto-generated method stub
	}

	public void onTestSuccess(ITestResult result)
	{
		// TODO Auto-generated method stub
	}

	public void onTestFailure(ITestResult result)
	{
		// TODO Auto-generated method stub
	}

	public void onTestSkipped(ITestResult result)
	{
		// TODO Auto-generated method stub
	}

	public void onTestFailedButWithinSuccessPercentage(ITestResult result)
	{
		// TODO Auto-generated method stub
	}

	public void onStart(ITestContext context)
	{
		// TODO Auto-generated method stub
	}
} // ends the class